<template>
  <div>
    <form>
      <label>姓名：</label>
      <input type="text" v-model.trim="uname" />
      <br />
      <br />

      <label>年龄：</label>
      <input type="number" v-model.number.trim="age" />
      <br />
      <br />

      <label>身高：</label>
      <input type="number" v-model.trim="sg" />(米)
      <br />
      <br />

      <label>体重：</label>
      <input type="number" v-model.number.trim="tz" />(公斤)
      <br />
      <br />

      <label>病史：</label>
      <input type="text" v-model.trim="bs" />
      <br />
      <br />

      <button @click.prevent="zd">诊断</button>
    </form>

    <p v-show="isshow">患者{{ uname }} 的诊断结果：{{ jieguo }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      uname: "",
      age: "",
      sg: "",
      tz: "",
      bs: "",
      jieguo: "",
      isshow: false,
    };
  },
  methods: {
    zd() {
      const BIM = (+this.tz / (+this.sg * +this.sg)).toFixed(2);
      this.isshow = true;
      // console.log(BIM);
      if (BIM > 18.5 && BIM <= 24) {
        this.jieguo = "健康";
      } else {
        this.jieguo = "不健康";
      }
    },
  },
};
</script>
